<%@page import="service.CategoryService"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="service.ArticleService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@include  file="../common/taglib.jsp"%>

<%
	ArticleService articleService = new ArticleService();
	List list = articleService.getArticlesAll();
	pageContext.setAttribute("list", list);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文章管理</title>
<link rel="stylesheet" type="text/css" href="${basePath}/static/css/public.css"/>
<link rel="stylesheet" type="text/css" href="${basePath}/static/css/index.css"/>

<script src="${basePath}/static/js/jQuery.js"></script>
<script src="${basePath}/static/layui/layui.all.js" charset="utf-8"></script>
<link rel="stylesheet" href="${basePath}/static/layui/css/layui.css" media="all">
</head>
<body>
	<h1>文章管理</h1>
	<a href="addArticle.jsp" class='fr'>
		<button type="button" class="layui-btn layui-btn-parmary">新增</button>
	</a>
	<table class="layui-table">
            <colgroup>
              <col width="50">
              <col width="150">
              <col width="150">
              <col width="150">
              <col width="150">
              <col width="200">
            </colgroup>
            <thead>
            <tr>
              <th>ID</th>
              <th>文章标题</th>
              <th>文章名称</th>
              <th>作者</th>
              <th>概要</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${list}" var="item" varStatus="status">
            	<tr>
	                <td>${status.index+1}</td>
	                <td>${item.header}</td>
	                <td>${item.name}</td>
	                <td>${item.author}</td>
	                <td>${item.description}</td>
	                <td>
	                  <button onclick="del('${item.id}')" type="button" class="layui-btn layui-btn-danger layui-btn-sm">删除</button>
	                </td>
	              </tr>
            </c:forEach>
              

            </tbody>
          </table>
	
	<script>
		function del(id){
			if(!confirm('您确定要删除这个类型吗？（此操作无法撤销）')){
	          return;
	        }
			location.href="deleteTypeController.jsp?id=" + id;
		}
		
	</script>
</body>
</html>
